<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
	<title>供应商信息</title>
   	<%@ include file="/WEB-INF/jsp/public/commons.jspf" %>
  <script type="text/javascript" >
  $(function() {

	var yz1;
	var yz2;
	var yz3 ;
	var aj=true;
if($("#yz1").val()!=""){
		$("#yz1").attr("readonly",true); 
	}else{
	
	function ajx(input) {
		//ajax
			$.ajax({
						type : "get",
						url : "${pageContext.request.contextPath}/supplier_ajx.do?name="
								+ input.value,
						dataType : "json",

						success : function(data) {
							if (data.success) {
								$("#msg1").html(data.msg);
								yz1 = false;
								aj=false;
							} else {
								$("#msg1").html("");
								yz1 = true;
								aj=true;
							}
						}
					});

		}
	}



		

	$("#yz1").blur(function() {
		// 验证是否为空
		if ($("#yz1").val().trim() == "") {
			$("#msg1").html("不能为空");
			yz1 = false;
		} else {
			ajx(this);
		}
	});

	$("#yz2").blur(function() {
		if ($("#yz2").val().trim() == "") {
			$("#msg2").html("不能为空");
			yz2 =false;
		} else {
			$("#msg2").html("");
			yz2 =true;
		}
	});

	$("#yz3").blur(function() {
		// 验证电话
		var reg = /^(\+\d{2,3}\-)?\d{11}$/;
		if (!reg.test($("#yz3").val())) {
			$("#msg3").html("请输入正确的电话号码!");
			yz3 = false;
		} else {
			$("#msg3").html("");
			yz3 = true;
		}
	});

	$("#save").bind("click", function() {
	
			// 验证是否为空
		if ($("#yz1").val().trim() == "") {
			$("#msg1").html("不能为空");
		}else{
			yz1=true;
		}
		
		if ($("#yz2").val().trim() == "") {
			$("#msg2").html("不能为空");
			
		} else{
			yz2=true;
		}
		
		var reg = /^(\+\d{2,3}\-)?\d{11}$/;
		if (!reg.test($("#yz3").val())) {
			$("#msg3").html("请输入正确的电话号码!");
		}else{
			yz3=true;
		}
			if(yz1&&yz2&yz3&aj){
			return true;}else{
			return false;
			}
		
	});
});
  </script>
</head>
<body>

<!-- 标题显示 -->
<div id="Title_bar">
    <div id="Title_bar_Head">
        <div id="Title_Head"></div>
        <div id="Title"><!--页面标题-->
            <img border="0" width="13" height="13" src="${pageContext.request.contextPath}/style/images/title_arrow.gif"/> 供应商信息
        </div>
        <div id="Title_End"></div>
    </div>
</div>

<!--显示表单内容-->
<div id=MainArea>

    <s:form action="supplier_%{id == null ? 'add' : 'save'}">
    	<s:hidden name="id"></s:hidden>
        
        <div class="ItemBlock_Title1"><!-- 信息说明 --><div class="ItemBlock_Title1">
        	<img border="0" width="4" height="7" src="${pageContext.request.contextPath}/style/blue/images/item_point.gif" /> 供应商信息</div> 
        </div>
        
        <!-- 表单内容显示 -->
        <div class="ItemBlockBorder">
            <div class="ItemBlock">
                <table cellpadding="0" cellspacing="0" class="mainForm">
                   <font color="red"><s:fielderror/></font>
                    <tr><td>名称</td>
                        <td><s:textfield id="yz1" name="name" cssClass="InputStyle"/> *<label id="msg1"></label></td>
                    </tr>
                     <tr><td>所在地</td>
                        <td><s:textfield id="yz2" name="address" cssClass="InputStyle"/> *<label id="msg2"></label></td>
                    </tr>
					
					<tr><td>电话号码</td>
                        <td><s:textfield id="yz3" name="phoneNumber" cssClass="InputStyle"/><label id="msg3"></label></td>
                    </tr>
                    
                </table>
            </div>
        </div>
        
	
        <!-- 表单操作 -->
        <div id="InputDetailBar">
            <input id="save" type="image" src="${pageContext.request.contextPath}/style/images/save.png"/>
            <a href="javascript:history.go(-1);"><img src="${pageContext.request.contextPath}/style/images/goBack.png"/></a>
        </div>
    </s:form>
</div>


</body>
</html>
